//Based on the tutorial at:
//http://artis.imag.fr/Membres/Xavier.Decoret/resources/ode/tutorial1.html

#include "Box.h"

Box::Box(dWorldID &world, dSpaceID &space, dReal width, dReal height, dReal depth, dReal mass)	
{	
	body = dBodyCreate(world);	
	geom = dCreateBox(space,width,height,depth);	

	dMass m;
	dMassSetBox(&m, 1.0f, width, height, depth);   	
	dMassAdjust(&m, mass);  
	dBodySetMass(body, &m);

	dGeomSetBody(geom,body); 
}
void Box::renderInLocalFrame() const
{
	dVector3 lengths;	
	dGeomBoxGetLengths(geom, lengths);	
	glScalef(lengths[0], lengths[1], lengths[2]);	
	glColor3ubv(color);

	GLfloat mat_specular[] = {0.1f, 0.1f, 0.1f};
	glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);

	glutSolidCube(1.0f);
}
